<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf8">
    <title>test</title>
  </head>
  <body>
	  <h1>it works!</h1>
    <script type="text/javascript">

      var path = require('path');
      var fs = require('fs');
      var testPath = path.join(fs.realpathSync('.'), 'test.js');
    

      global.xhr = new XMLHttpRequest();
      var test = require(testPath);
      test.xhr();
      global.xhr.open('GET', 'http://127.0.0.1:8123/img.jpg', true);
      global.xhr.responseType = 'arraybuffer';
      global.xhr.send(null);

      setTimeout(function(){
        var socket = require('net').connect({port: 13013});
        socket.setEncoding('utf8');
        socket.end('write');

      },2000);
    </script>
  </body>
</html>
    
